<template>
  <div id="app">
    <ul>
      <li v-for="(item,index) in data" :key="index">
        <span>{{item}}</span>
        <button @click="del(index)">删除</button>
      </li>
    </ul>
    <button @click="pro">生成</button>
  </div>
</template>
 
<script>
export default {
  data() {
    return {
      data: [1, 2],
    };
  },
  methods: {
    pro() {
      let suiji = Math.floor(Math.random() * 10);
      this.data.push(suiji);
      console.log(suiji)
    },
    del(a) {
      this.data.splice(a, 1);
    },
  },
};
</script>


  <style>

  </style>



